from django.db import models


class BrandModel(models.Model):
    name = models.CharField(max_length=30)

    class Meta:
        db_table = 'brand'

    def __str__(self):
        return self.name


class CarModel(models.Model):
    carname = models.CharField(max_length=30)
    brand = models.ForeignKey(to=BrandModel, on_delete=models.CASCADE)
    img = models.CharField(max_length=300)

    class Meta:
        db_table = 'car'

    def __str__(self):
        return self.carname


class CateModel(models.Model):
    name = models.CharField(max_length=30)

    class Meta:
        db_table = 'cate'

    def __str__(self):
        return self.name


class BookModel(models.Model):
    name = models.CharField(max_length=30)
    cate = models.ForeignKey(to=CateModel, on_delete=models.CASCADE)
    img = models.CharField(max_length=300)

    class Meta:
        db_table = 'book'

    def __str__(self):
        return self.name





